# load library
library(Seurat)
library(tidyverse)
library(RCurl)
library(cowplot)
library(RColorBrewer)
library(scater)
library(dplyr)
library(SingleR)
library(celldex)
seurat_integrated <- readRDS("results/integrated_seurat_singlets.rds")
DimPlot(seurat_integrated, reduction = "umap", label = TRUE, pt.size = .1)

mo_ref <- celldex::MouseRNAseqData()
cell_cluster <- SingleR(test = as.SingleCellExperiment(seurat_integrated),ref = mo_ref, labels = mo_ref$label.main)
# Display the counts of cells in each pruned label category
table(cell_cluster$pruned.labels)
##
## Astrocytes Endothelial cells Epithelial cells Fibroblasts
## 215 21 3 45
## Microglia Neurons Oligodendrocytes T cells
## 219 11540 2922 1
# Assign the cell_cluster labels to the seurat_integrated object
seurat_integrated$cell_cluster <- cell_cluster$pruned.labels
# Create a dimensional plot using UMAP reduction, grouping by 'cell_cluster' with labels
DimPlot(seurat_integrated, reduction = "umap", group.by = 'cell_cluster', label = T)
# Check the length of active.ident in seurat_integrated
# This gives the number of cells after removing 'NA' cell cluster labels
seurat_integrated <- subset(seurat_integrated, cell_cluster != 'NA')
length(seurat_integrated@active.ident)
## [1] 14966
# save
seu_obj <- readRDS("./results_inuse/clean_seu_obj_close.rds")
DimPlot(seu_obj, group.by= 'major_cluster',pt.size = 0.1, label = T, label.size = 3)+ NoLegend()
# Check the length of active.ident in seu_obj
# This gives the number of cells in seu_obj
length(seu_obj@active.ident)
## [1] 10995
# save
DimPlot(seu_obj, pt.size = 0.1, label = F, label.size = 3)
Center for Integrative Brain Research, Seattle Children’s Research Institute, 1900 9th Ave, Seattle, WA, USA, hema.bhagavan@seattlechildrens.org↩︎